<?php
/**
 * @author Yannic Schnetz < yannicschne@gmx.de >
 * @copyright Yannic Schnetz < yannicschne@gmx.de >
 *
 * @since 06.12.2011
 */
 
 // Seiten verwalten (News) //
if(isset($_GET['page']) && is_numeric($_GET['page'])) {
	$page = $_GET['page'];
	} else {
	$page = 1;
	}

$per_page = $config['home']['news_per_page'];
$start = ($page == 1) ? $per_page : $page * $per_page - $per_page;
$num = $cDB->num("SELECT * FROM `news`");
$max_page = ceil($num / $per_page);
$max_page = ($max_page == 0) ? 1 : $max_page;

// News von der bestimmten Seite holen
$news = array();
$query = $cDB->query("SELECT * FROM `news` ORDER BY `stamp` DESC LIMIT $start, $per_page");
while($row = $cDB->fetch($query))	{
	$row['autorname'] = User::sGetUsernameById($row['autorid']);
	$row['stamp'] = date("d.m.Y H:i", $row['stamp']);
	$news[] = $row;
	}

// Anzahl der SLIDE-News abfragen (Config)
$limit = $config['home']['news_slides'];

// Slide News holen
$news_slide = array();
$query = $cDB->query("SELECT * FROM `news` WHERE `ishot` = '1' ORDER BY `stamp` DESC LIMIT $limit");
while($row = $cDB->fetch($query))	{
	$row['autorname'] = User::sGetUsernameById($row['autorid']);
	$row['stamp'] = date("d.m.Y H:i", $row['stamp']);
	$news_slide[] = $row;
	}

// Ans Template senden
$smarty->assign('news', $news);
$smarty->assign('max_page', $max_page);
$smarty->assign('page', $page);
$smarty->assign('news_slide', $news_slide);
?>